---
description:
  GraphQL-CLI was wrapping the commands implemented in GraphQL-Inspector, in order to provide a
  unified experience. You can switch to using GraphQL-Inspector directly.
---

import { Callout, Tabs } from '@theguild/components'

# Migrating from GraphQL-CLI to Inspector CLI

As such, it's a good idea to start thinking about migrating to using `graphql-inspector` directly -
it is actively maintained and supported, and provides the same functionality as GraphQL-CLI with
some additional, new features.

<Callout type="warning">The package @graphql-cli is deprecated, and no longer maintained!</Callout>

## Introduction

Today, GraphQL-CLI was wrapping the commands implemented in GraphQL-Inspector, in order to provide a
unified experience. You can switch to using GraphQL-Inspector directly.

## Migration Steps

The migration from GraphQL-CLI to Inspector CLI is relatively straightforward. Here are the steps
you can take:

1. Install Inspector CLI: You can install Inspector CLI using NPM by running the following command:

```sh npm2yarn
npm i --global @graphql-inspector/cli graphql
```

2. Replace graphql-cli with graphql-inspector in your commands: After installing Inspector CLI,
   you'll need to replace all instances of graphql in your commands with graphql-inspector.

For example, if you were previously using the following command to validate your schema with
GraphQL-CLI:

```sh
graphql validate './documents/*.graphql' http://localhost:3000/graphql
```

You would now use the following command with Inspector CLI:

```sh
graphql-inspector validate './documents/*.graphql' http://localhost:3000/graphql
```

## Examples

Here are examples of how to perform some common actions with both GraphQL-CLI and Inspector CLI:

### Introspect

<Tabs items={['Before (GraphQL - CLI)', 'After (GraphQL-Inspector)']}>
<Tabs.Tab>
```sh
graphql get-schema --endpoint=https://api.example.com/graphql --header="Authorization: Bearer YOUR_TOKEN" > schema.graphql
```
</Tabs.Tab>
<Tabs.Tab>
```sh
graphql-inspector introspect https://api.example.com/graphql --headers '{"Authorization": "Bearer YOUR_TOKEN"}' > schema.graphql
```
</Tabs.Tab>
</Tabs>

### Validate

<Tabs items={['Before (GraphQL - CLI)', 'After (GraphQL-Inspector)']}>
<Tabs.Tab>
```sh
graphql validate './documents/*.graphql' http://localhost:3000/graphql
```
</Tabs.Tab>
<Tabs.Tab>
```sh
graphql-inspector validate './documents/\*.graphql' http://localhost:3000/graphql
```
</Tabs.Tab>
</Tabs>

### Diff

<Tabs items={['Before (GraphQL - CLI)', 'After (GraphQL-Inspector)']}>
<Tabs.Tab>
```sh
graphql diff schema.graphql schema2.graphql
```
</Tabs.Tab>
<Tabs.Tab>
```sh
graphql-inspector diff schema.graphql schema2.graphql
```
</Tabs.Tab>
</Tabs>

### Common

<Tabs items={['Before (GraphQL - CLI)', 'After (GraphQL-Inspector)']}>
<Tabs.Tab>
```sh
graphql common schema.graphql schema2.graphql
```
</Tabs.Tab>
<Tabs.Tab>
```sh
graphql-inspector common schema.graphql schema2.graphql
```
</Tabs.Tab>
</Tabs>

### Coverage

<Tabs items={['Before (GraphQL - CLI)', 'After (GraphQL-Inspector)']}>
<Tabs.Tab>
```sh
graphql coverage schema.graphql --queries="queries/**/*.graphql"
```
</Tabs.Tab>
<Tabs.Tab>
```sh
graphql-inspector coverage schema.graphql --queries "queries/**/*.graphql"
```
</Tabs.Tab>
</Tabs>

### Similar

<Tabs items={['Before (GraphQL - CLI)', 'After (GraphQL-Inspector)']}>
<Tabs.Tab>
```sh
graphql similar schema.graphql schema2.graphql
```
</Tabs.Tab>
<Tabs.Tab>
```sh
graphql-inspector similar schema.graphql schema2.graphql
```
</Tabs.Tab>
</Tabs>

## Conclusion

Migrating from GraphQL-CLI to Inspector CLI is a relatively simple process. By following the steps
outlined in this post and updating your commands, you can continue to use a powerful and actively
maintained tool for analyzing and manipulating GraphQL schemas.

Inspector CLI offers a number of useful actions, including common, coverage, diff, introspect,
similar, and validate. With these actions, you can perform a wide range of tasks, from generating
schemas to validating changes and analyzing coverage.

If you're still using GraphQL-CLI and want to take advantage of the additional features and benefits
offered by Inspector CLI, we highly recommend migrating as soon as possible. With Inspector CLI,
you'll have a more powerful and flexible tool for working with GraphQL schemas, and you'll be better
equipped to handle the evolving needs of your GraphQL workflow.
